package com.baichang.taoshunda.controller.mobile;

import com.baichang.framework.controller.BaseMobileController;
import com.baichang.framework.controller.IService;
import com.baichang.framework.excelption.ServiceException;
import com.baichang.taoshunda.controller.ControllerConstants;
import com.baichang.taoshunda.service.FavoritesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by ${wushenglu} on 17/08/26.
 */
@Controller
@RequestMapping(ControllerConstants.FAVOITES)
public class FavoritesMCtronller extends BaseMobileController {
    @Autowired
    private FavoritesService favoritesService;

    /**
     * 我的收藏
     */
    @RequestMapping("/myFavoites")
    public void myFavoites(HttpServletRequest request, HttpServletResponse response) {
        initEncode(request, response, new IService() {
            @Override
            public Object init(HttpServletRequest request, HttpServletResponse response, String json) throws ServiceException {
                int userId = getInt(json, "userId", 24);
                int typeId = getInt(json, "typeId", 1);//  1普通商家 2本地服务商家 3商品
                int nowPage = getInt(json, "nowPage", 1);
                double ulng = getDouble(json, "ulng", 117.147482);
                double ulat = getDouble(json, "ulat", 36.656933);
                return favoritesService.myFavoites(ulat, ulng, userId, typeId, nowPage, 20);
            }
        });
    }
}
